<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Models\Usersauthority;
use App\Services\CacheService;
use DB,Log,Exception;

class Usersauthoritys extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'users:authority';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '部分用户没有权限配置数据(可删除)';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        DB::table("users")->select("id","miniapp_style","miniapp_third")->where("id",">",31710)->orderBy('id')->chunk(1000, function ($users) {
            foreach ($users as $user) {
                Usersauthority::createUsersAuthority($user->id,$user->miniapp_style,$user->miniapp_third);
                dump($user->id);
            }
        });
    }
}
